#ifndef PROJECTMANAGER_GLOBAL_H
#define PROJECTMANAGER_GLOBAL_H

#include <QtCore/qglobal.h>

#include "objlib.h"

#if defined(PROJECTMANAGER_LIBRARY)
#  define PROJECTMANAGER_EXPORT Q_DECL_EXPORT
#else
#  define PROJECTMANAGER_EXPORT Q_DECL_IMPORT
#endif

class ProMgr_PubFunc
{
public:

    static QString AutoCreateName(const QString& text,QList<QString> listNames,QString prevStr)
    {
        QString newText = text;
        if (newText == "")//text= "" 则 自动命名
        {
            int prevLen = prevStr.length();
            bool ok = false;
            int maxNum = 1;
            for (int i = 0; i< listNames.count(); i++)
            {
                QString name = listNames.at(i);
                if (name.left(prevLen) == prevStr)
                {
                    int number = name.mid(prevLen,name.length() - prevLen).toInt(&ok);
                    if (ok && number >= maxNum)
                        maxNum = number + 1;
                }
            }
            newText = prevStr+QString::number(maxNum);
        }
        else
        {
            //判断是否有重命名
            for (int i = 0; i< listNames.count(); i++)
            {
                QString name = listNames.at(i);
                if (name == newText)
                {
                    newText = "";
                    break;
                }
            }
        }
        return newText;
    }



};





#endif // PROJECTMANAGER_GLOBAL_H
